<template>
  <!-- :cell-class-name="num===0?'undrag':''" -->
  <!--单个列展示-->
  <el-table-column
    :key="col.key"
    :prop="col.prop"
    :label="col.label"
    :width="col.width"
    :align="col.align || 'right'"
    :show-overflow-tooltip="col.tooltip"
    :render-header="renderHeader"
    header-align="center"
  >
    <!--递归遍历children属性-->
    <template v-if="col.children && col.children.length > 0">
      <multi-level-colums
        v-for="(item, index) in col.children"
        :key="index"
        :col="item"
      />
    </template>
  </el-table-column>
</template>
<script>
import { mapActions } from 'vuex';
import promptMessage from '@/components/business/MultiLevelColums/promptMessage';
export default {
  name: 'MultiLevelColums',
  props: {
    col: {
      type: Object,
      required: true,
      default: () => {}
    }
  },
  created() {
    this.init();
  },
  methods: {
    ...mapActions({ 'getFormulaList': 'diclist/getFormulaList' }),
    init() {
      this.getFormulaList();
    },
    renderHeader(h, { column }) {
      // console.log(column);
      if (column.level === 1 && column.label.trim() !== '行标签') {
        return h('div', [
          h('span', column.label),
          h(promptMessage, {
            props: { messages: column.label }
          })
        ]);
      }
      return h('span', column.label);
    }
  }
};
</script>

<style lang="scss">
  .title-center {
    text-align: center !important;
  }
  .el-table__header-wrapper {
    .el-table__header {
      .is-group {
          .el-table_1_column_1 .is-left .is-leaf {
            text-align: center !important;
          }
      }
    }
  }

</style>
